<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/19 0019
 * Time: 00:03
 */

namespace app\common\validate;

use think\Validate;

class Member extends Validate
{
    protected $rule = [
        'username|会员账号' => 'require|unique:member',
        'password|密码' => 'require',
        'conpass|确认密码' => 'require|confirm:password',
        'verify|验证码' => 'require|captcha',
        'oldpassword|原密码' => 'require',
        'newpassword|新密码' => 'require'
    ];

    public function sceneAdd()
    {
        return $this->only(['username', 'password']);
    }

    public function sceneEdit()
    {
        return $this->only(['oldpassword', 'newpassword']);
    }

    public function sceneLogin()
    {
        return $this->only(['username', 'password', 'verify'])
            ->remove('username', 'unique');
    }

    public function sceneRegister()
    {
        return $this->only(['username', 'password', 'verify', 'conpass']);
    }
}